package com.card.framework.util;

import java.util.List;
import java.util.Map;

import com.card.framework.mybatis.optimist.ModifiedByAnotherUserException;

import net.sf.json.JSONArray;



public class CommonUtil {
	@SuppressWarnings({ "unchecked", "deprecation" })
	public static <T> List <T> getBean(String str , Class<T> type) {
		JSONArray arr = JSONArray.fromObject(str);
		return JSONArray.toList(arr, type);
	}
	
	public static void throwsException(Map<String, String> map,Throwable e){
		e.printStackTrace();
		map.put("mes", "操作失败</br>"+e.getMessage());
		while(e.getCause()!=null){
			if(e.getCause() instanceof ModifiedByAnotherUserException){
				map.put("mes", "数据已过时,请刷新.");
			}
			e = e.getCause();
		}
	}
}